package com.gjzt.business.web.controller;

import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.eastdigit.servlet.ReqBean;
import com.eastdigit.servlet.RequestAttribute;
import com.eastdigit.servlet.Response;
import com.gjzt.business.web.service.WebService;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping(value = "/web")
public class WebController {

    @Autowired
    private WebService webService;

    /**
     * 查询车辆或者站点
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/queryBusOrStop")
    @ResponseBody
    public JSONObject queryBusOrStop(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(webService.queryBusOrStop(reqBean));
    }


    /**
     * 资源检查查询
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/resCheckQuery")
    @ResponseBody
    public JSONObject resCheckQuery(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(webService.resCheckQuery(reqBean));
    }

    /**
     * 转发请求
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/changeOAuth")
    @ResponseBody
    public JSONObject changeOAuth(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean,HttpServletRequest request) throws Exception {
        return Response.responseSuccess(webService.changeOAuth(reqBean,request));
    }

    /**
     * 资源检查模糊搜索
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/resCheckFuzzyQuery")
    @ResponseBody
    public JSONObject resCheckFuzzyQuery(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(webService.resCheckFuzzyQuery(reqBean));
    }


    @RequestMapping(value = "/queryCurrentBillDetail")
    @ResponseBody
    public JSONObject queryCurrentBillDetail(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(webService.queryCurrentBillDetail(reqBean));
    }

}
